import { Button, Modal } from 'antd';
import React, { useState } from 'react';
import '../../../assets/css/Car/Ycjl.css'
import Ycbiaoge from '../ycbiaoge/Ycbiaoge';
import axios from '../../../utils/axios'


const Ycjl = (props) => {
  
  const [isModalVisible, setIsModalVisible] = useState(false);
  const [tabData, setTabData] = useState([]);
  const showModal = () => {
    setIsModalVisible(true);
    getycjlarr()
    console.log(props.msg);
  
  };

  const handleOk = () => {
    setIsModalVisible(false);
  };

  const handleCancel = () => {
    setIsModalVisible(false);
  };


const getycjlarr=()=>{
  axios({
    url: "/car/carPage/findUseCarByNumber",
    method: "get",
    params: {
      carNumber:props.msg,
    }
  }).then((res) => {
     setTabData(res.data);
    console.log(res);
  }).then((err) => {
    console.log(err);
  })
}
  return (
    <>
      <Button type="primary" onClick={showModal} className='ybtn' >
        用车记录
      </Button>
      <Modal title="用车记录"
        visible={isModalVisible}
        onOk={getycjlarr }
        onCancel={handleCancel}
        className='Mbox'>
        <Ycbiaoge list={tabData}></Ycbiaoge>
      </Modal>
    </>
  );
};

export default Ycjl;
